package reflect;

import reflect.annotations.AutoRunClass;

import java.io.File;
import java.net.URISyntaxException;

public class Test3 {
    public static void main(String[] args) throws Exception {
        File dir = new File(
                Test3.class.getResource("."
                ).toURI()
        );
        File[] files = dir.listFiles(f -> f.getName().endsWith(".class"));
        for (File file : files) {
            String className = file.getName().substring(0, file.getName().indexOf("."));
            Class cls = Class.forName(Test3.class.getPackage().getName() + "." + className);
            if (cls.isAnnotationPresent(AutoRunClass.class)) {
                System.out.println(cls.getSimpleName() + ":有被@AutoRunClass标注");
            } else {
                System.out.println(cls.getSimpleName() + ":没有被@AutoRunClass标注");
            }
        }
    }
}
